//
//  loadExcelViewController.swift
//  HuaYun
//
//  Created by enghou on 2018/7/13.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

import UIKit

import QuickLook

class loadExcelViewController: QLPreviewController,QLPreviewControllerDataSource,QLPreviewControllerDelegate {
    func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
        return 1
    }
    
    func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
        return path! as QLPreviewItem
    }

    var path: PreviewURL?
    
    let webView = UIWebView.init()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.dataSource = self
        
        self.delegate = self
        // Do any additional setup after loading the view.
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
    }
    
    override func viewWillLayoutSubviews() {
        
        super.viewWillLayoutSubviews()
        
    }

    override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
        
        if path?.previewItemURL != nil {
            do{
                try FileManager.default.removeItem(at: path!.previewItemURL!)
            }catch{
                print(error)
            }
        }
        
        
        super.dismiss(animated: flag, completion: completion)
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
